/** * GOOGLE API - AS3 LIBRARY * * @author Joris Timmerman * @version 3.0 * * GoogleApi - GoogleAPI Wrapper Class * Build by Joris Timmerman, this is a wrappper class for all possible api methods. * * These classes are using methods and classes from the Adobe Core Libary, downloadable @ http://code.google.com/p/as3corelib/ * * SPECIAL THANKS TO GOOGLE FOR PROVIDING THE AJAX API * THIS IS AN OPEN SOURCE PROJECT DELIVERED BY BOULEVART NV (www.boulevart.be) */package be.boulevart.google {	import be.boulevart.google.api.calculator.GoogleCalculator;
	import be.boulevart.google.api.calculator.GoogleCurrencyConverter;
	import be.boulevart.google.api.core.GoogleAPIKeyStore;
	import be.boulevart.google.api.feeds.GoogleFeeds;
	import be.boulevart.google.api.search.blogs.GoogleBlogSearch;
	import be.boulevart.google.api.search.books.GoogleBookSearch;
	import be.boulevart.google.api.search.images.GoogleImageSearch;
	import be.boulevart.google.api.search.local.GoogleLocalSearch;
	import be.boulevart.google.api.search.news.GoogleNewsSearch;
	import be.boulevart.google.api.search.patents.GooglePatentSearch;
	import be.boulevart.google.api.search.videos.GoogleVideoSearch;
	import be.boulevart.google.api.search.web.GoogleWebSearch;
	import be.boulevart.google.api.suggest.GoogleSuggest;
	import be.boulevart.google.api.translate.GoogleTranslate;
	import be.boulevart.google.api.weather.GoogleWeather;
	
	import com.adobe.utils.StringUtil;

	public class GoogleAPI {		private var _blogs:GoogleBlogSearch;		private var _books:GoogleBookSearch;		private var _calculator:GoogleCalculator;		private var _currencyConverter:GoogleCurrencyConverter;		private var _feeds:GoogleFeeds;		private var _images:GoogleImageSearch;		private var _local:GoogleLocalSearch;		private var _news:GoogleNewsSearch;		private var _patents:GooglePatentSearch;		private var _suggest:GoogleSuggest;		private var _translate:GoogleTranslate;		private var _videos:GoogleVideoSearch;		private var _web:GoogleWebSearch;		private var _weather:GoogleWeather;		/**		 * When making new instance of this class, all API classes will be instantiated.<br/>		 * You can signup for an API key here: <a href="http://code.google.com/intl/us-en/apis/ajaxsearch/signup.html">http://code.google.com/intl/us-en/apis/ajaxsearch/signup.html</a>		 *  @example Use it like this:		 *		 * <listing version="3.0">		 * var google:GoogleApi=new GoogleApi();		 * google.web.search(txtInput.text,0,lang);		 * google.web.addEventListener(GoogleSearchEvent.WEB_SEARCH_RESULT,onWebResults) ;		 *		 * //If you want to catch the API errors yourself:		 * google.web.addEventListener(GoogleAPIErrorEvent.API_ERROR,onAPIError)		 *		 * private function onWebResults(e:GoogleSearchEvent):void{		 *         var resultObject:GoogleSearchResult=e.data as GoogleSearchResult		 *         trace("Estimated Number of Results: "+resultObject.estimatedNumResults)		 *         trace("Current page index: "+resultObject.currentPageIndex)		 *         trace("Number of pages: "+resultObject.numPages)		 *		 *         for each (var result:GoogleWebItem in resultObject.results){		 *                 trace(result.title, result.url)		 *         }		 * }		 *		 * private function onAPIError(evt:GoogleAPIErrorEvent):void{		 *         trace("An API error has occured: " + evt.responseDetails, "responseStatus was: " + evt.responseStatus);		 * }		 * </listing>		 * @param apiKey Enter your Google API key for the AJAX searches here (optional).		 */		public function GoogleAPI(apiKey:String = ""):void {			blogs = new GoogleBlogSearch();			books = new GoogleBookSearch();			calculator = new GoogleCalculator();			currencyConverter = new GoogleCurrencyConverter();			feeds = new GoogleFeeds();			images = new GoogleImageSearch();			local = new GoogleLocalSearch();			news = new GoogleNewsSearch();			patents = new GooglePatentSearch();			suggest = new GoogleSuggest();			translate = new GoogleTranslate();			videos = new GoogleVideoSearch();			web = new GoogleWebSearch();			weather = new GoogleWeather();			if (StringUtil.trim(apiKey).length > 0) {				GoogleAPIKeyStore.setAPIKey(apiKey);			}		}		/**		 * Google Blog Search		 */		public function get blogs():GoogleBlogSearch {			return _blogs;		}		public function set blogs(value:GoogleBlogSearch):void {			_blogs = value;		}		/**		 * Google Book Search		 */		public function get books():GoogleBookSearch {			return _books;		}		public function set books(value:GoogleBookSearch):void {			_books = value;		}		/**		 * Google calculator		 */		public function get calculator():GoogleCalculator {			return _calculator;		}		public function set calculator(value:GoogleCalculator):void {			_calculator = value;		}		/**		 * Google currency converter		 */		public function get currencyConverter():GoogleCurrencyConverter {			return _currencyConverter;		}		public function set currencyConverter(value:GoogleCurrencyConverter):void {			_currencyConverter = value;		}		/**		 * Google Feeds Search		 */		public function get feeds():GoogleFeeds {			return _feeds;		}		public function set feeds(value:GoogleFeeds):void {			_feeds = value;		}		/**		 * Google Image Search		 */		public function get images():GoogleImageSearch {			return _images;		}		public function set images(value:GoogleImageSearch):void {			_images = value;		}		/**		 * Google Local Search		 */		public function get local():GoogleLocalSearch {			return _local;		}		public function set local(value:GoogleLocalSearch):void {			_local = value;		}		/**		 * Google News Search		 */		public function get news():GoogleNewsSearch {			return _news;		}		public function set news(value:GoogleNewsSearch):void {			_news = value;		}		/**		 * Google Patent Search		 */		public function get patents():GooglePatentSearch {			return _patents;		}		public function set patents(value:GooglePatentSearch):void {			_patents = value;		}		/**		 * Google Suggest (search hints)		 */		public function get suggest():GoogleSuggest {			return _suggest;		}		public function set suggest(value:GoogleSuggest):void {			_suggest = value;		}		/**		 * Google Translate		 */		public function get translate():GoogleTranslate {			return _translate;		}		public function set translate(value:GoogleTranslate):void {			_translate = value;		}		/**		 * Google Video Search		 */		public function get videos():GoogleVideoSearch {			return _videos;		}		public function set videos(value:GoogleVideoSearch):void {			_videos = value;		}		/**		 * Google Web Search		 */		public function get web():GoogleWebSearch {			return _web;		}		public function set web(value:GoogleWebSearch):void {			_web = value;		}		/**		 * Google Weather Search		 */		public function get weather():GoogleWeather {			return _weather;		}		public function set weather(value:GoogleWeather):void {			_weather = value;		}	}}